package SFT;
import java.util.ArrayList;
import java.util.List;


/**represents a function that is a linear combination of chiFunctions*/
public class MultChi extends abstractFunction {

	/*the list of the chi's in the linear combination defined by MultChi*/
	private List<ChiFunction> chiList;
	/*the size of the cyclic group on which this function is defined.*/
	private int size;
	
	
	public MultChi(int size) {
		chiList= new ArrayList<ChiFunction>();
		this.size=size;
	}
	
	/*Adds a new character with coefficient "coeff" to the list. The character will have a frequency
	 * of "n" cycles per "size", where size is the size of the group. */
	public void add_Chi(int n, Complex coeff)
	{
		chiList.add(new ChiFunction(n, size,coeff));
	}
	
	
	@Override
	public Complex apply(int i) {
		Complex sum=new Complex();
		for (ChiFunction cf : chiList) {
			sum.Add(cf.apply(i));
			
		}
		return sum;
	}


	@Override
	public double infNorm(int startIndex, int endIndex) {
		return 1;
	}

	@Override
	public int maxVal() {
		return size-1;
	}

	public void add_Chi(double doubleValue, Complex coeff) {
		chiList.add(new ChiFunction(doubleValue, size,coeff));
	}

}
